#include <iostream>
#include <signal.h>

using namespace std;

void handler(int signo)
{
    cout << "System signal: " << signo << "replaced by handler!" << endl;
    exit(signo);
}


int main()
{
    // "ctrl + c" will be identified is "2" signal then send to process
    signal(SIGINT, handler);    // handler(SIGINT)

    for(int i = 0; i < 10; i++)
    {
        if(i == 5)
        {
            // 1.The  raise()  function  sends a signal to the calling process or thread
            //raise(SIGINT);
            // 2.The abort() function first unblocks the SIGABRT signal, and then raises that signal for the calling process
            abort();    // -> SIGABRT
        }
        cout << "singal_test is running..." << endl;
        sleep(1);
    }
    return 0;
}